import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'login',
    component: () => import(/* webpackChunkName: "Home" */ '../views/login.vue')
  },
  {
    path: '/main',
    name: 'main',
    component: () => import(/* webpackChunkName: "Home" */ '../views/main'),
    redirect:{
      name:"overview"
    },
    children:[
      {
        path: 'overview',
        name: 'overview',
        component: () => import(/* webpackChunkName: "Home" */ '../views/main/overview')
      },
      {
        path: 'detail/:id',
        name: 'detail',
        props: true,
        component: () => import(/* webpackChunkName: "modelDetail" */ '../views/main/overview/detail')
      },{
        path: 'maillist',
        name: 'maillist',
        component: () => import('../views/main/overview/maliList/index')
      },{
        path: 'product',
        name: 'product',
        component: () => import('../views/main/overview/product/index')
      },{
        path: 'knowledge',
        name: 'knowledge',
        component: () => import('../views/main/overview/knowledge/index')
      }
    ]
  }

]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})


export default router
